package com.miyake.dsp.osa.lab.wrapper;

import com.miyake.dsp.osa.lab.Calculator;
import com.miyake.dsp.osa.lab.LabUiAnnotation;
import com.miyake.dsp.osa.lab.Sort;
@LabUiAnnotation(caption="Sort")
public class SortWrapper extends Calculator {
	public static final String INPUT_X = "Input x";
	public static final String INPUT_Y = "Input y";
	public static final String OUTPUT_X = "Output x";
	public static final String OUTPUT_Y = "Output y";
	
	public SortWrapper() {
		initInput(INPUT_X);
		initInput(INPUT_Y);
		initOutput(OUTPUT_X);
		initOutput(OUTPUT_Y);
	}
	
	@Override
	public synchronized void process() {
		double[] y = this.getInput(INPUT_Y).getRealPart();
		double[] x;
		
		if (this.getInput(INPUT_X) != null) {
			x = this.getInput(INPUT_X).getRealPart();
		}
		else {
			x = new double[y.length];
			for (int i = 0; i < y.length; i++) {
				x[i] = i;
			}
		}
		
		Sort sort = new Sort(x, y);
		
		setOutput(OUTPUT_X, sort.getOutx());
		setOutput(OUTPUT_Y, sort.getOuty());
	}

	@Override
	public Object getSetting() {
		return null;
	}

}
